home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 22 / Cream of the Crop 22.iso / windows / wdj1096.zip / TOMLINSN.ZIP / STARTSRV.C < prev    next >
C/C++ Source or Header  |  1996-07-15  |  675b  |  28 lines

  1. // startsrv.c
  2.  
  3. #include "windows.h"
  4.  
  5. BOOL StartedAsService(LPSERVICE_TABLE_ENTRY ServiceTable)
  6. {
  7.     OSVERSIONINFO OsVerInfo;
  8.  
  9.     OsVerInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  10.     GetVersionEx(&OsVerInfo);
  11.     if (OsVerInfo.dwPlatformId != VER_PLATFORM_WIN32_NT) {
  12.         return FALSE;   // not NT - not started by SCM
  13.     }
  14.  
  15.     // Attempt to connect to  the service control manager
  16.     if (!StartServiceCtrlDispatcher(ServiceTable)) {
  17.         if (GetLastError() ==
  18.                 ERROR_FAILED_SERVICE_CONTROLLER_CONNECT) {
  19.             return FALSE;   // not started by SCM
  20.         }
  21.     }
  22.  
  23.     return TRUE;
  24.  
  25. } // IsStartedAsService
  26.  
  27.  
  28.